package com.bdyc.test;

import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.alibaba.fastjson.JSONObject;
import com.bdyc.controller.custom.OrderGroup;
import com.bdyc.controller.custom.PcategoryInfoPo;
import com.bdyc.controller.custom.UserInfoPo;
import com.bdyc.po.WcategoryInfo;
import com.bdyc.service.spring.OrderInfoService;
import com.bdyc.service.spring.PcategoryInfoService;
import com.bdyc.service.spring.UserInfoService;
import com.bdyc.service.spring.WcategoryInfoService;


public class App3 {

//	@Autowired
//	@Qualifier("fastWriteInfoService")
//	private FastWriteInfoService fastWriteInfoServiceImpl;
	
//	//操作快写mapper
//		@Autowired(required=true)
//		@Qualifier("orderInfoMapper")
//		private OrderInfoMapper orderInfoMapper;
//		@Autowired(required=true)
//		@Qualifier("orderWriteRelMapper")
//		private OrderWriteRelMapper orderWriteRelMapper;
//		@Autowired(required=true)
//		@Qualifier("userOrderRelMapper")
//		private UserOrderRelMapper userOrderRelMapper;
//	
////	@Test
//	public void testSping() {
//		ApplicationContext ac = new ClassPathXmlApplicationContext("spring.xml");
//		
////		UserOrderRelMapper userOrderRelMapper = (UserOrderRelMapper) ac.getBean("userOrderRelMapper");
//		userOrderRelMapper.deleteByOId(4);
//		OrderInfoMapper orderInfoMapper =(OrderInfoMapper)ac.getBean("orderInfoMapper");
//		orderInfoMapper.deleteById(5);
//		OrderWriteRelMapper orderWriteRelMapper = (OrderWriteRelMapper)ac.getBean("orderWriteRelMapper");
//		orderWriteRelMapper.deleteByWId(4);
//		FastWriteInfoService fastWriteInfoService =(FastWriteInfoService)ac.getBean("fastWriteInfoService");
//		FastWriteInfo fastWriteInfo = fastWriteInfoService.findFastWriteInfoByOId(11);
//		System.out.println(fastWriteInfo);
//	}
//	
//	@Test
//	public void app(){
//		ApplicationContext ac = new ClassPathXmlApplicationContext("spring.xml");
//		FastWriteInfoService fastWriteInfoService =(FastWriteInfoService)ac.getBean("fastWriteInfoService");
//		FastWriteInfo fw = new FastWriteInfo();
//		fw.setName("电脑发布计划");
//		fw.setPrice(10000f);
//		fw.setDescDiff("有哪些类似产品跟竞品最大的不同在于？");
//		fw.setDescQues("期望撰稿角度");
//		fw.setDescBack("你们现在处于第几轮融资，融资金额？团队背景？");
//		fw.setDescAche("你的产品解决的痛点是什么？");
//		fw.setDescFun("你的产品的主要功能和服务是？");
//		fw.setDescThree("进入这个行业不得不解决的哪三个问题");
//		fastWriteInfoService.addFastWtireInfo(fw, 1);
//	}
//	@Test
//	public void app2(){
//		ApplicationContext ac = new ClassPathXmlApplicationContext("spring.xml");
//		OrderInfoService orderInfoServiceImpl =(OrderInfoService)ac.getBean("orderInfoService");
//		Map<String,Object> map = new HashMap<String,Object>();
//		Integer page=2;
//		Integer rows = 4;
//		Integer uid=1;
//		map.put("page", page);
//		map.put("rows", rows);
//		map.put("uid", uid);
//		List<OrderInfo> orderList =orderInfoServiceImpl.findAllByUserId(map);
//		for (OrderInfo orderInfo : orderList) {
//			System.out.println(orderInfo);
//		}
//	}
//	@Test
//	public void update(){
//		ApplicationContext ac = new ClassPathXmlApplicationContext("spring.xml");
//		FastWriteInfoService fastWriteInfoServiceImpl =(FastWriteInfoService)ac.getBean("fastWriteInfoService");
//		FastWriteInfo fw = new FastWriteInfo();
//		fw.setName("电脑发布计划2222");
//		fw.setId(39);
//		fw.setPrice(22222f);
//		fw.setDegree("1,2");
//		fw.setKeyword(Integer.valueOf("2"));
//		fw.setDescDiff("有哪些类似产品跟竞品最大的不同在于？");
//		fw.setDescQues("期望撰稿角度");
//		fw.setDescBack("你们现在处于第几轮融资，融资金额？团队背景？");
//		fw.setDescAche("你的产品解决的痛点是什么？");
//		fw.setDescFun("你的产品的主要功能和服务是？");
//		fw.setDescThree("进入这个行业不得不解决的哪三个问题");
//		fastWriteInfoServiceImpl.updateFastWriteInfo(fw);
//	}
//	@Test
	@SuppressWarnings("resource")
	public void appAddUserInfo(){
		ApplicationContext ac = new ClassPathXmlApplicationContext("spring.xml");
//		ManagerInfoService managerInfoService =(ManagerInfoService) ac.getBean("managerInfoService");
		UserInfoService userInfoServiceImpl = (UserInfoService)ac.getBean("userInfoService");
		Map<String,Object> countMap = new HashMap<String,Object>();
		countMap.put("rows", 10);
		countMap.put("page",1);
//		countMap.put("name", "zhang");
//		countMap.put("realName", "李");
//		countMap.put("name", "z");
//		Integer a = userInfoServiceImpl.findUserInfoListCount(countMap);
//		System.out.println(a);
		UserInfoPo us = userInfoServiceImpl.login("admin1", "123456");
		System.out.println(JSONObject.toJSONString(us));
//		List<UserInfoPo> list = userInfoServiceImpl.findUserInfoList(countMap);
//		for (UserInfoPo userInfoPo : list) {
//			System.out.println(JSONObject.toJSONString(userInfoPo));
//		}
//		Map<String,Object> sendMap = new HashMap<String,Object>();
//		sendMap.put("realName", "馒头");
//		sendMap.put("rid", 1);
//		sendMap.put("rows", 10);
//		sendMap.put("page", 1);
//		Integer a = managerInfoService.findUserInfoListCount(sendMap); 
//		System.out.println(a);
//		List<ManagerInfoPo> list = managerInfoService.findUserInfoList(sendMap);
//		for (ManagerInfoPo managerInfo : list) {
//			System.out.println(JSONObject.toJSONString(managerInfo));
//		}
	}
//	@Test
	@SuppressWarnings({ "resource", "unused" })
	public void testOrder() throws ParseException{
		ApplicationContext ac = new ClassPathXmlApplicationContext("spring.xml");
		OrderInfoService orderInfoServiceImpl =(OrderInfoService)ac.getBean("orderInfoService");
		Map<String,Object> sendMap = new HashMap<String,Object>();
//		sendMap.put("flag", 1);
//		sendMap.put("status", 1);
//		sendMap.put("uid", 1);
//		sendMap.put("rows", 10);
//		sendMap.put("page", 1);
//		sendMap.put("start",new Date(MyDateFormat.getStartDate("2016-04-29")));
//		sendMap.put("end", new Date(MyDateFormat.getEndDate("2016-04-30")));
//		Integer a = orderInfoServiceImpl.findOrderInfoListCount(sendMap);
//		System.out.println(a);
//		List<OrderInfoPo> orderInfoList = orderInfoServiceImpl.findOrderInfoList(sendMap);
//		for (OrderInfoPo orderInfoPo : orderInfoList) {
//			System.out.println(JSONObject.toJSONString(orderInfoPo));
//		}
		List<OrderGroup> og =  orderInfoServiceImpl.groupFlag();
		for (OrderGroup orderGroup : og) {
			System.out.println(JSONObject.toJSONString(orderGroup));
		}
		Integer flag = 1;
		List<OrderGroup> or = orderInfoServiceImpl.groupStatus(flag);
		for (OrderGroup orderGroup : or) {
			System.out.println(JSONObject.toJSONString(orderGroup));
		}
	}
//	@Test
	@SuppressWarnings("resource")
	public void category(){
		ApplicationContext ac = new ClassPathXmlApplicationContext("spring.xml");
		WcategoryInfoService wcategoryInfoServiceImpl = (WcategoryInfoService)ac.getBean("wcategoryInfoService");
		Map<String,Object> sendMap = new HashMap<String,Object>();
		sendMap.put("rows", 10);
		sendMap.put("page", 1);
		sendMap.put("name", "王");
		List<WcategoryInfo> list = wcategoryInfoServiceImpl.findCategoryInfoList(sendMap);
		for (WcategoryInfo wcategoryInfo : list) {
			System.out.println(wcategoryInfo);
		}
	}
	@SuppressWarnings("resource")
	@Test
	public void category2(){
		/*ApplicationContext ac = new ClassPathXmlApplicationContext("spring.xml");
		DcategoryInfoService dcategoryInfoServiceImpl = (DcategoryInfoService)ac.getBean("dcategoryInfoService");*/
		ApplicationContext ac = new ClassPathXmlApplicationContext("spring.xml");
		PcategoryInfoService pcategoryInfoServiceImpl = (PcategoryInfoService)ac.getBean("pcategoryInfoService");
		Map<String,Object> sendMap = new HashMap<String,Object>();
		sendMap.put("rows", 10);
		sendMap.put("page", 1);
		sendMap.put("name", "王");
		Integer a  = pcategoryInfoServiceImpl.findCategoryInfoCount(sendMap);
		List<PcategoryInfoPo> list = pcategoryInfoServiceImpl.findCategoryInfo(sendMap);
		for (PcategoryInfoPo pcategoryInfoPo : list) {
			System.out.println(JSONObject.toJSONString(pcategoryInfoPo));
		}
//		for (DcategoryInfo dcategoryInfo : list) {
//			System.out.println(JSONObject.toJSONString(dcategoryInfo));
//		}
		System.out.println(a);
	}
}







